package com.atguigu.srb.core.controller.api;

import com.atguigu.srb.core.service.UserInfoService;
import com.atguigu.srb.core.service.WxUserInfoService;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * ClassName: ApiWxLoginController
 * Package: com.atguigu.srb.core.controller.api
 * Description:
 *
 * @Author 王晓龙
 * @Create 2023/4/2 15:47
 * @Version 1.0
 */
@Controller
@Api("微信登录管理")
@RequestMapping("/api/wx")
public class ApiWxLoginController {
    @Resource
    WxUserInfoService wxUserInfoService;

    @GetMapping("/login")
    //让访问的用户去扫码
    public String wxLogin(HttpSession session){
        return wxUserInfoService.wxLogin(session);
    }

    @GetMapping("/callback")
    public String callBack(String code, String state, HttpSession session, HttpServletRequest request) throws IOException {
        return wxUserInfoService.callback(code, state, session, request);
    }
}